/*
 * @Author: 2112778581 2112778581@qq.com
 * @Date: 2023-10-16 10:13:29
 * @LastEditors: 2112778581 2112778581@qq.com
 * @LastEditTime: 2023-10-16 13:28:38
 * @FilePath: \pra\libs\db\src\models\news.model.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { ApiProperty } from '@nestjs/swagger';
import { modelOptions, prop, Ref } from '@typegoose/typegoose';
import { IsNotEmpty, Allow, IsOptional } from 'class-validator';

@modelOptions({
  // 自动为每个属性添加时间戳
  schemaOptions: {
    timestamps: true,
  },
})
export class Category {
  @ApiProperty({ description: '分类名称' })
  @IsNotEmpty({ message: '分类名称不能为空' })
  @prop()
  name: string;

  @ApiProperty({ description: '父级id', required: true })
  @prop({ ref: () => Category })
  @IsOptional()
  parent: Ref<Category>;

  @Allow()
  _id: string;

  @Allow()
  createdAt: string;

  @Allow()
  updatedAt: string;

  @Allow()
  __v: string;
}
